<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta name="viewport"
	content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=8">
<meta http-equiv="Expires" content="0">
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Cache-control" content="no-cache">
<meta http-equiv="Cache" content="no-cache">
<title>灵犀详情</title>
<script src="javascript/jquery.min.js"></script>
<script src="javascript/function.js"></script>
<link rel="stylesheet" href="stylesheet/style_v1.1.css">
</head>
<body>
<div class="header-title">
    <a href="javascript:void(0);" class="fanhui">
        <img src="image/tick.png" alt="">
    </a>
    <p>祈福详细</p>
</div>
<div class="con padding-top50 padding-bottom50" >
    <div class="work-ms padding-lr5">
        <p class="name" id="detailName"></p>
        <p class="shuoming" id="detailContent"></p>
        <p class="qifu-jiage">价值 ￥<span id="detailMoney"></span>元</p>
        <input type="text" class="inputs" placeholder="被祈福人：亲人、朋友、基友..." id="username" >
        <input type="number" class="inputs" placeholder="设定单人单价，例：19.9" id="price" value="9.99">
        <span class="qifu-shuoming">
<!--             说明：<br> -->  
                <b>灵犀一下</b>：<br>1)、发起祈福，邀请好友帮忙聚福（灵犀一下）。<br>2)、每次祈福需要18份好友帮忙。完成后可兑换麦道月饼礼品一份（价值180元）。<br>3)、好友帮你聚福（灵犀一下）的过程中，系统也会帮你为你的好友聚福一次。正可谓“心有灵犀”。<br>
<!--             <b>被祈福人</b>：填写接受祈福的人，可以是亲人、爱人、朋友、同学、基友...<br> -->
<!--             <b>设定单人单价</b>：设定每个帮助祈福人需要支付的金额；<br> -->
        </span>
    </div>
    <div class="col-12 padding5">
        <a href="javascript:void(0);" class="btn" onclick="startClifford();">确认</a>
    </div>
</div>
<script>
var goodsId='<%=request.getParameter("parms.goodsId")%>';
        $(function(){
        	queryCliffordDetail();
        });
        function queryCliffordDetail() {
   		var params = "parms.goodsId=" + goodsId;
    	$.ajax({
    				type : 'post',
    				url : 'cliffordAction!queryCliffordDetail.action',
    				async : false,
   					data : params, // 传给action的参数
    				success : function(data) {
    					if (data.result == 1) {
    						if (data.resultData.size == '0') {
    							alert("未获取到商品信息");
    						} else {
    							var list = data.resultData.datalist;
    							document.getElementById("detailName").innerHTML = list[0][0].goodsName;
    							document.getElementById("detailContent").innerHTML = list[0][0].goodsDes;
    							document.getElementById("detailContent").innerHTML = list[0][0].goodsStorePrice;
    						}
    					} else {
    						alert(data.msg);
    					}
    				}
    			});
    }
        function startClifford(){
//         	alert("创建"+goodsId+"祈福记录");
        	var params = "parms.goodsId=" + goodsId;
        	params+="&parms.openId=" + "1";
        	params+="&parms.owner_price=" + $("#price").val();
        	params+="&parms.cliffordName=" + $("#username").val();
        	$.ajax({
        				type : 'post',
        				url : 'cliffordAction!startClifford.action',
        				async : false,
       					data : params, // 传给action的参数
        				success : function(data) {
        					if (data.result == 1) {
        						window.location.href="forwardPageParam_cliffordUserList.action?parms.config="+goodsId+"_"+data.resultData.cliffordId+"_1";
        					}else if(data.result == 2){
        						alert("灵犀成功："+data.msg);
        						window.location.href="forwardPageParam_cliffordUserList.action?parms.config="+goodsId+"_"+data.resultData.cliffordId+"_1";
        					} else {
        						alert("灵犀失败："+data.msg);
        					}
        				}
        			});
        }
    </script>

</body>
</html>